/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DeleteProductManager;

import java.sql.*;
import DBManager.DBConnection;

/**
 *
 * @author Alex
 */
public class DeleteProductManager {
    
      public boolean deleteProduct(Product newProduct)
    {
        boolean result = false;
        
        try{
            //get connection
            DBConnection db = new DBConnection();
            Connection conn = db.getConnection();
            
            //Construct SQL Query
            PreparedStatement pstmt =
                conn.prepareStatement("DELETE FROM products WHERE title=?");
            
            //append values for the parameters
            int i=1;

            pstmt.setString(i++, newProduct.getTitle());
            
            //execute SQL statement
            pstmt.executeUpdate();
            
            result = true;
        }
        catch(SQLException ex){ex.printStackTrace();}
        
        return result;
    }
}
